
package cz.czu.pef.DataModelling.beans;

import java.io.Serializable;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import javax.faces.context.FacesContext;


@ManagedBean(name = "skinBean")
@SessionScoped
public class SkinBean implements Serializable
{
	private static final long serialVersionUID = -1141458655571944167L;

	public String skin = "blueSky"; // default value
	private Object skinChooserState;

	//private static final String defaultSkins[] = {"DEFAULT", "plain", "blueSky", "classic", "deepMarine", "emeraldTown", "japanCherry", "ruby", "wine"};

	/**
	 * @return String
	 */
	public String getSkin()
	{
		String param = getSkinParam();
		if (param != null)
		{
			setSkin(param);
		}
		return skin;
	}

	public void setSkin(String skin)
	{
		this.skin = skin;
	}

	private String getSkinParam()
	{
		FacesContext fc = FacesContext.getCurrentInstance();
		String param = (String) fc.getExternalContext().getRequestParameterMap().get("s");
		if (param != null && param.trim().length() > 0)
		{
			return param;
		}
		else
		{
			return null;
		}
	}


	public String changeSkin()
	{
		String param = getSkinParam();
		if (param != null)
		{
			setSkin(param);
		}
		return null;
	}

	public Object getSkinChooserState()
	{
		return skinChooserState;
	}

	public void setSkinChooserState(Object skinChooserState)
	{
		this.skinChooserState = skinChooserState;
	}
}
